<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<?php $this->load->view('admin/header.html')?>
<script type="text/javascript" src="<?php echo base_url()?>common/js/validateForm.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>common/js/ck.js"></script>
<script type="text/javascript">
    function Success(data) {
        $.Success(data);
    }

    function EnableGoods(did) {
        var url = "/admin/recovery/enable_goods/" + did + "?returnurl=<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>";
        layer.confirm("确定启用该商品", function () {
            $.post(url, null, function (data) {
                var jsonData = $.parseJSON(data);
                if (jsonData.Statu == 'ok') {
                    Success(jsonData)
                }
                else {
                    Success(jsonData)
                }
            })
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }
    function BatchEnable() {
        layer.confirm("确定要启用这些商品？？", function (index) {
            if ($("#checkboxVal").val().length <= 0) {
                layer.msg('未选择商品！', { icon: 0 });
                return false;
            }
            var url = "/admin/recovery/batchenable_goods?returnurl=<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']?>";
            $.post(url, { "items": $("#checkboxVal").val() }, function (data) {
                if (data.Statu == "ok") {
                    Success(data)
                    $("#allcheck").attr("checked", false)
                } else {
                    Success(data)
                }
            }, "json")
        }, function () {
            layer.msg('取消删除', { icon: 0 });
        })
    }


</script>
<div id="dcMain">
    <!-- 当前位置 -->
    <div id="urHere">
        DouPHP 管理中心
        <b>></b>
        <strong>商品管理</strong>
    </div>
    <div id="manager" class="mainBox" style="height:auto!important;height:550px;min-height:550px;">
        <table width="100%" border="0" cellpadding="8" cellspacing="0" class="tableBasic">
            <tr>
                <th width="50" align="center"><label for="allcheck">选择</label> <input type="checkbox" id="allcheck" name="allcheck" class="allcheck" /></th>
                <th width="30" align="center">编号</th>
                <th align="left">商品名称</th>
                <th align="left">缩略图</th>
                <th align="left">总库存</th>
                <th align="center">操作</th>
            </tr>
            <?php foreach($goodsList as $goodsItem):?>
            <tr>
                <td align="center"><input type="checkbox" name="cklist" value="<?php echo $goodsItem->goods_id;?>" /></td>
                <td align="center"><?php echo $goodsItem->goods_id;?></td>

                <td><?php echo $goodsItem->title;?></td>
                <td><img src="<?php echo $goodsItem->imgurl;?>" style="height:40px;width:35px;" /></td>
                <td><?php echo $goodsItem->inventory_count;?></td>
                <td align="center">
                    <a href="<?php echo site_url('admin/recovery/viewgoods/'.$goodsItem->goods_id)?>?return=<?php echo 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]?>">查看</a>|
                    <a href="javascript:EnableGoods(<?php echo $goodsItem->goods_id?>)">启用</a>
                </td>
            </tr>
            <?php endforeach; ?>
            <tr>
                <td colspan="10"><a href="javascript:BatchEnable()">全部启用</a></td>
            </tr>
        </table>
        <input type="hidden" value="" id="checkboxVal" />
        <div class='page'>
            <?php echo $links?>
        </div>
    </div>
</div>